An Introduction to Movement Ecology in R

Jed Long

Western University

Welcome

About

Objectives

  1. Learn basics of wildlife tracking data

  2. Discover R packages for working with tracking data

  3. Learn how to make maps and animations of tracking data

  4. Perform basic analytical procedures:

    1. movement metrics
    2. space use analysis
  5. get exposed to more advanced techniques

The Basics of Wildlife Tracking Data

What are wildife tracking data?

Wildilfe Tracking Data

Download file from https://github.com/jedalong/Movement-Ecology-in-R/DeerGPS_MoveEcolWorkshop.csv

x <- read.csv('Data/DeerGPS_MoveEcolWorkshop.csv')
head(x)
           ID YEAR MONTH DAY HOUR MINUTE SECOND LONGITUDE LATITUDE ALT Dim SAT1
1 d16241y2011 2011     5   1    0      2     37 -97.26100 34.01511 252   3    4
2 d16241y2011 2011     5   1    0     32     41 -97.26103 34.01510 243   3    2
3 d16241y2011 2011     5   1    1      2     37 -97.26128 34.01490 238   3    2
4 d16241y2011 2011     5   1    1     32     36 -97.26148 34.01305 252   3    2
5 d16241y2011 2011     5   1    2      2     37 -97.26132 34.01291 252   3    2
6 d16241y2011 2011     5   1    2     32     37 -97.26118 34.01297 247   3    2
  SAT2 SAT3 SAT4 SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP
1   10   17   20   28    0    0    0    0     0     0     0  3.8  2.8 25.75
2    4   10   12   17   28    0    0    0     0     0     0  2.2  1.2 27.69
3    4    9   10   12   17   27    0    0     0     0     0  2.6  1.1 25.19
4    4    5    9   10   12   17   27    0     0     0     0  2.4  1.1 25.31
5    4    5    9   10   12   17   25    0     0     0     0  1.7  0.9 25.44
6    4    5    9   10   12   17   25    0     0     0     0  1.6  1.0 25.31
  ACTIVITY TIMEON
1      473     37
2        0     41
3      631     37
4      485     36
5      127     37
6      215     37

Dates & Times

  • Date/Time in separate fields
  • Date/Time in single field
  • function strptime for formatting
x$date <- paste(x$MONTH,"/",x$DAY,"/",x$YEAR," ",
                x$HOUR,":",x$MINUTE,":",x$SECOND,sep="")

x$date1 <- strptime(x$date, "%m/%d/%Y %H:%M:%S")

Dates & Times

  • POSIX objects
    • widely used in tracking packages
    • easy extraction of date/time features (like tod)
  • Easier formatting using ‘lubridate’ (we won’t use here)
x$POSIX <- as.POSIXct(x$date1)
summary(x[,c('date1','POSIX')])
     date1                           POSIX                      
 Min.   :2011-05-01 00:02:36.0   Min.   :2011-05-01 00:02:36.0  
 1st Qu.:2011-05-08 17:32:41.0   1st Qu.:2011-05-08 17:32:41.0  
 Median :2011-05-16 11:32:37.0   Median :2011-05-16 11:32:37.0  
 Mean   :2011-05-16 11:44:52.5   Mean   :2011-05-16 11:44:52.5  
 3rd Qu.:2011-05-24 06:02:37.0   3rd Qu.:2011-05-24 06:02:37.0  
 Max.   :2011-05-31 23:32:40.0   Max.   :2011-05-31 23:32:40.0  

Spatial Data

  • Vector data using sf package
  • Older spatial sp package
    • most tracking packages still use sp objects
library(sf)
deersf <- st_as_sf(x, coords=c('LONGITUDE','LATITUDE'))
deersf
Simple feature collection with 11837 features and 29 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: -97.27711 ymin: 34.00079 xmax: -97.20812 ymax: 34.02629
CRS:           NA
First 10 features:
            ID YEAR MONTH DAY HOUR MINUTE SECOND ALT Dim SAT1 SAT2 SAT3 SAT4
1  d16241y2011 2011     5   1    0      2     37 252   3    4   10   17   20
2  d16241y2011 2011     5   1    0     32     41 243   3    2    4   10   12
3  d16241y2011 2011     5   1    1      2     37 238   3    2    4    9   10
4  d16241y2011 2011     5   1    1     32     36 252   3    2    4    5    9
5  d16241y2011 2011     5   1    2      2     37 252   3    2    4    5    9
6  d16241y2011 2011     5   1    2     32     37 247   3    2    4    5    9
7  d16241y2011 2011     5   1    3      2     47 249   3    2    4    5   10
8  d16241y2011 2011     5   1    3     32     36 251   3    2    5   10   12
9  d16241y2011 2011     5   1    4      2     40 253   3    2    5   10   12
10 d16241y2011 2011     5   1    4     32     37 264   3    2    5   12   15
   SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP ACTIVITY TIMEON
1    28    0    0    0    0     0     0     0  3.8  2.8 25.75      473     37
2    17   28    0    0    0     0     0     0  2.2  1.2 27.69        0     41
3    12   17   27    0    0     0     0     0  2.6  1.1 25.19      631     37
4    10   12   17   27    0     0     0     0  2.4  1.1 25.31      485     36
5    10   12   17   25    0     0     0     0  1.7  0.9 25.44      127     37
6    10   12   17   25    0     0     0     0  1.6  1.0 25.31      215     37
7    12   25   29    0    0     0     0     0  3.2  1.7 26.69       87     47
8    25   29    0    0    0     0     0     0  4.4  1.7 26.44        0     36
9    21   25   26   29    0     0     0     0  1.8  0.9 26.00        0     40
10   21   25   26   29    0     0     0     0  2.4  1.0 20.25      298     37
               date               date1               POSIX
1   5/1/2011 0:2:37 2011-05-01 00:02:37 2011-05-01 00:02:37
2  5/1/2011 0:32:41 2011-05-01 00:32:41 2011-05-01 00:32:41
3   5/1/2011 1:2:37 2011-05-01 01:02:37 2011-05-01 01:02:37
4  5/1/2011 1:32:36 2011-05-01 01:32:36 2011-05-01 01:32:36
5   5/1/2011 2:2:37 2011-05-01 02:02:37 2011-05-01 02:02:37
6  5/1/2011 2:32:37 2011-05-01 02:32:37 2011-05-01 02:32:37
7   5/1/2011 3:2:47 2011-05-01 03:02:47 2011-05-01 03:02:47
8  5/1/2011 3:32:36 2011-05-01 03:32:36 2011-05-01 03:32:36
9   5/1/2011 4:2:40 2011-05-01 04:02:40 2011-05-01 04:02:40
10 5/1/2011 4:32:37 2011-05-01 04:32:37 2011-05-01 04:32:37
                     geometry
1    POINT (-97.261 34.01511)
2   POINT (-97.26103 34.0151)
3   POINT (-97.26128 34.0149)
4  POINT (-97.26148 34.01305)
5  POINT (-97.26132 34.01291)
6  POINT (-97.26118 34.01297)
7  POINT (-97.26117 34.01295)
8  POINT (-97.26118 34.01297)
9  POINT (-97.26118 34.01297)
10    POINT (-97.261 34.0129)

Coordinate Systems

deersf <- st_as_sf(x, coords=c('LONGITUDE','LATITUDE'), crs=4326)
deersf
Simple feature collection with 11837 features and 29 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: -97.27711 ymin: 34.00079 xmax: -97.20812 ymax: 34.02629
Geodetic CRS:  WGS 84
First 10 features:
            ID YEAR MONTH DAY HOUR MINUTE SECOND ALT Dim SAT1 SAT2 SAT3 SAT4
1  d16241y2011 2011     5   1    0      2     37 252   3    4   10   17   20
2  d16241y2011 2011     5   1    0     32     41 243   3    2    4   10   12
3  d16241y2011 2011     5   1    1      2     37 238   3    2    4    9   10
4  d16241y2011 2011     5   1    1     32     36 252   3    2    4    5    9
5  d16241y2011 2011     5   1    2      2     37 252   3    2    4    5    9
6  d16241y2011 2011     5   1    2     32     37 247   3    2    4    5    9
7  d16241y2011 2011     5   1    3      2     47 249   3    2    4    5   10
8  d16241y2011 2011     5   1    3     32     36 251   3    2    5   10   12
9  d16241y2011 2011     5   1    4      2     40 253   3    2    5   10   12
10 d16241y2011 2011     5   1    4     32     37 264   3    2    5   12   15
   SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP ACTIVITY TIMEON
1    28    0    0    0    0     0     0     0  3.8  2.8 25.75      473     37
2    17   28    0    0    0     0     0     0  2.2  1.2 27.69        0     41
3    12   17   27    0    0     0     0     0  2.6  1.1 25.19      631     37
4    10   12   17   27    0     0     0     0  2.4  1.1 25.31      485     36
5    10   12   17   25    0     0     0     0  1.7  0.9 25.44      127     37
6    10   12   17   25    0     0     0     0  1.6  1.0 25.31      215     37
7    12   25   29    0    0     0     0     0  3.2  1.7 26.69       87     47
8    25   29    0    0    0     0     0     0  4.4  1.7 26.44        0     36
9    21   25   26   29    0     0     0     0  1.8  0.9 26.00        0     40
10   21   25   26   29    0     0     0     0  2.4  1.0 20.25      298     37
               date               date1               POSIX
1   5/1/2011 0:2:37 2011-05-01 00:02:37 2011-05-01 00:02:37
2  5/1/2011 0:32:41 2011-05-01 00:32:41 2011-05-01 00:32:41
3   5/1/2011 1:2:37 2011-05-01 01:02:37 2011-05-01 01:02:37
4  5/1/2011 1:32:36 2011-05-01 01:32:36 2011-05-01 01:32:36
5   5/1/2011 2:2:37 2011-05-01 02:02:37 2011-05-01 02:02:37
6  5/1/2011 2:32:37 2011-05-01 02:32:37 2011-05-01 02:32:37
7   5/1/2011 3:2:47 2011-05-01 03:02:47 2011-05-01 03:02:47
8  5/1/2011 3:32:36 2011-05-01 03:32:36 2011-05-01 03:32:36
9   5/1/2011 4:2:40 2011-05-01 04:02:40 2011-05-01 04:02:40
10 5/1/2011 4:32:37 2011-05-01 04:32:37 2011-05-01 04:32:37
                     geometry
1    POINT (-97.261 34.01511)
2   POINT (-97.26103 34.0151)
3   POINT (-97.26128 34.0149)
4  POINT (-97.26148 34.01305)
5  POINT (-97.26132 34.01291)
6  POINT (-97.26118 34.01297)
7  POINT (-97.26117 34.01295)
8  POINT (-97.26118 34.01297)
9  POINT (-97.26118 34.01297)
10    POINT (-97.261 34.0129)

Changing Coordinate Systems

  • Easiest done as sf object
  • NAD83 UTM Zone 14N is code 3158
# Convert to NAD83 UTM Zone 14N
deersf_utm <- st_transform(deersf,crs=3158)
head(deersf_utm)
Simple feature collection with 6 features and 29 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 660533.8 ymin: 3764950 xmax: 660574.7 ymax: 3765194
Projected CRS: NAD83(CSRS) / UTM zone 14N
           ID YEAR MONTH DAY HOUR MINUTE SECOND ALT Dim SAT1 SAT2 SAT3 SAT4
1 d16241y2011 2011     5   1    0      2     37 252   3    4   10   17   20
2 d16241y2011 2011     5   1    0     32     41 243   3    2    4   10   12
3 d16241y2011 2011     5   1    1      2     37 238   3    2    4    9   10
4 d16241y2011 2011     5   1    1     32     36 252   3    2    4    5    9
5 d16241y2011 2011     5   1    2      2     37 252   3    2    4    5    9
6 d16241y2011 2011     5   1    2     32     37 247   3    2    4    5    9
  SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP ACTIVITY TIMEON
1   28    0    0    0    0     0     0     0  3.8  2.8 25.75      473     37
2   17   28    0    0    0     0     0     0  2.2  1.2 27.69        0     41
3   12   17   27    0    0     0     0     0  2.6  1.1 25.19      631     37
4   10   12   17   27    0     0     0     0  2.4  1.1 25.31      485     36
5   10   12   17   25    0     0     0     0  1.7  0.9 25.44      127     37
6   10   12   17   25    0     0     0     0  1.6  1.0 25.31      215     37
              date               date1               POSIX
1  5/1/2011 0:2:37 2011-05-01 00:02:37 2011-05-01 00:02:37
2 5/1/2011 0:32:41 2011-05-01 00:32:41 2011-05-01 00:32:41
3  5/1/2011 1:2:37 2011-05-01 01:02:37 2011-05-01 01:02:37
4 5/1/2011 1:32:36 2011-05-01 01:32:36 2011-05-01 01:32:36
5  5/1/2011 2:2:37 2011-05-01 02:02:37 2011-05-01 02:02:37
6 5/1/2011 2:32:37 2011-05-01 02:32:37 2011-05-01 02:32:37
                  geometry
1 POINT (660574.7 3765194)
2 POINT (660571.5 3765193)
3 POINT (660549.3 3765170)
4 POINT (660533.8 3764965)
5 POINT (660548.6 3764950)
6   POINT (660562 3764956)

GEOMETRY column

  • sf uses geometry columns
  • add back the coordinates as separate columns
deersf_utm$X <- st_coordinates(deersf_utm)[,1]  
deersf_utm$Y <- st_coordinates(deersf_utm)[,2]
deer_utm <- st_drop_geometry(deersf_utm)
head(deer_utm)
           ID YEAR MONTH DAY HOUR MINUTE SECOND ALT Dim SAT1 SAT2 SAT3 SAT4
1 d16241y2011 2011     5   1    0      2     37 252   3    4   10   17   20
2 d16241y2011 2011     5   1    0     32     41 243   3    2    4   10   12
3 d16241y2011 2011     5   1    1      2     37 238   3    2    4    9   10
4 d16241y2011 2011     5   1    1     32     36 252   3    2    4    5    9
5 d16241y2011 2011     5   1    2      2     37 252   3    2    4    5    9
6 d16241y2011 2011     5   1    2     32     37 247   3    2    4    5    9
  SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP ACTIVITY TIMEON
1   28    0    0    0    0     0     0     0  3.8  2.8 25.75      473     37
2   17   28    0    0    0     0     0     0  2.2  1.2 27.69        0     41
3   12   17   27    0    0     0     0     0  2.6  1.1 25.19      631     37
4   10   12   17   27    0     0     0     0  2.4  1.1 25.31      485     36
5   10   12   17   25    0     0     0     0  1.7  0.9 25.44      127     37
6   10   12   17   25    0     0     0     0  1.6  1.0 25.31      215     37
              date               date1               POSIX        X       Y
1  5/1/2011 0:2:37 2011-05-01 00:02:37 2011-05-01 00:02:37 660574.7 3765194
2 5/1/2011 0:32:41 2011-05-01 00:32:41 2011-05-01 00:32:41 660571.5 3765193
3  5/1/2011 1:2:37 2011-05-01 01:02:37 2011-05-01 01:02:37 660549.3 3765170
4 5/1/2011 1:32:36 2011-05-01 01:32:36 2011-05-01 01:32:36 660533.8 3764965
5  5/1/2011 2:2:37 2011-05-01 02:02:37 2011-05-01 02:02:37 660548.6 3764950
6 5/1/2011 2:32:37 2011-05-01 02:32:37 2011-05-01 02:32:37 660562.0 3764956

Why R for Movement Ecology?

Movement Ecology in R

  • “Recent” paper outlined R ecosystem for movement ecology (Joo et al. 2020, J. An. Ecol.)

Joo et al. 2020, Figure 4

Movement Ecology in R

R Workflows

  • We are going to focus on key steps in the typical workflow:

Joo et al. 2020, Figure 2

Handling Tracking Data

  • Two primary packages (IMO): ‘move’ and ‘adehabitatLT’
    • see also: ‘trajr’, ‘amt’, ‘trajectories’
  • Both have advantages and disadvantages
  • I primarily use ‘adehabitatLT’ so we will focus on that here
library(adehabitatLT)

AdehabitatLT Package

  • Core structure: ltraj trajectory objects
    • Originated in 2006!
  • Easily incorporates multiple individuals
    • can incorporate “bursts” within individuals
  • Automatically computes movement metrics (discussed later)
  • Used as input into various analysis
  • Can handle “No Time” tracks (e.g., footprints)

AdehabitatLT Package

deer_ltraj <- as.ltraj(xy=deer_utm[,c('X','Y')],        #Spatial Coordinates
                       date = deer_utm$POSIX,           #Date/times
                       id = deer_utm$ID,                #individual IDs
                       infolocs=deer_utm[,c('PDOP','ACTIVITY')], #other data
                       proj4string = CRS("+init=epsg:3158"))   #coordinate reference
deer_ltraj

*********** List of class ltraj ***********

Type of the traject: Type II (time recorded)
* Time zone unspecified: dates printed in user time zone *
Irregular traject. Variable time lag between two locs

Characteristics of the bursts:
           id       burst nb.reloc NAs          date.begin            date.end
1 d16241y2011 d16241y2011     1486   0 2011-05-01 00:02:37 2011-05-31 23:32:39
2 d16243y2011 d16243y2011     1480   0 2011-05-01 00:02:40 2011-05-31 23:32:37
3 d16244y2011 d16244y2011     1474   0 2011-05-01 00:02:36 2011-05-31 23:32:39
4 d16246y2011 d16246y2011     1481   0 2011-05-01 00:02:36 2011-05-31 23:32:40
5 d16247y2011 d16247y2011     1482   0 2011-05-01 00:02:37 2011-05-31 23:32:40
6 d16250y2011 d16250y2011     1474   0 2011-05-01 00:02:37 2011-05-31 23:32:37
7 d16252y2011 d16252y2011     1487   0 2011-05-01 00:02:40 2011-05-31 23:32:36
8 d16253y2011 d16253y2011     1473   0 2011-05-01 00:02:40 2011-05-31 23:32:36


 infolocs provided. The following variables are available:
[1] "PDOP"     "ACTIVITY"

Recap 1: Tracking Data in adehabitatLT

Installing Packages

  • Use ‘install.packages(’PackageName’) to install a package
  • Need to call library(PackageName) in every R session
#install.packages('sf')
library(sf)
library(adehabitatLT)
library(sp)

Reading in Data

Download file from https://github.com/jedalong/Movement-Ecology-in-R/DeerGPS_MoveEcolWorkshop.csv

x <- read.csv('Data/DeerGPS_MoveEcolWorkshop.csv') #explore the data
x$date <- paste(x$MONTH,"/",x$DAY,"/",x$YEAR," ",
                x$HOUR,":",x$MINUTE,":",x$SECOND,sep="")
x$date1 <- strptime(x$date, "%m/%d/%Y %H:%M:%S")
x$POSIX <- as.POSIXct(x$date1)
head(x)
           ID YEAR MONTH DAY HOUR MINUTE SECOND LONGITUDE LATITUDE ALT Dim SAT1
1 d16241y2011 2011     5   1    0      2     37 -97.26100 34.01511 252   3    4
2 d16241y2011 2011     5   1    0     32     41 -97.26103 34.01510 243   3    2
3 d16241y2011 2011     5   1    1      2     37 -97.26128 34.01490 238   3    2
4 d16241y2011 2011     5   1    1     32     36 -97.26148 34.01305 252   3    2
5 d16241y2011 2011     5   1    2      2     37 -97.26132 34.01291 252   3    2
6 d16241y2011 2011     5   1    2     32     37 -97.26118 34.01297 247   3    2
  SAT2 SAT3 SAT4 SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP
1   10   17   20   28    0    0    0    0     0     0     0  3.8  2.8 25.75
2    4   10   12   17   28    0    0    0     0     0     0  2.2  1.2 27.69
3    4    9   10   12   17   27    0    0     0     0     0  2.6  1.1 25.19
4    4    5    9   10   12   17   27    0     0     0     0  2.4  1.1 25.31
5    4    5    9   10   12   17   25    0     0     0     0  1.7  0.9 25.44
6    4    5    9   10   12   17   25    0     0     0     0  1.6  1.0 25.31
  ACTIVITY TIMEON             date               date1               POSIX
1      473     37  5/1/2011 0:2:37 2011-05-01 00:02:37 2011-05-01 00:02:37
2        0     41 5/1/2011 0:32:41 2011-05-01 00:32:41 2011-05-01 00:32:41
3      631     37  5/1/2011 1:2:37 2011-05-01 01:02:37 2011-05-01 01:02:37
4      485     36 5/1/2011 1:32:36 2011-05-01 01:32:36 2011-05-01 01:32:36
5      127     37  5/1/2011 2:2:37 2011-05-01 02:02:37 2011-05-01 02:02:37
6      215     37 5/1/2011 2:32:37 2011-05-01 02:32:37 2011-05-01 02:32:37

Transform Spatial Coordinates

deersf <- st_as_sf(x,coords=c('LONGITUDE','LATITUDE'),crs=4326)
deersf_utm <- st_transform(deersf,crs=3158)
deersf_utm$X <- st_coordinates(deersf_utm)[,1]  
deersf_utm$Y <- st_coordinates(deersf_utm)[,2]
deer_utm <- st_drop_geometry(deersf_utm)
head(deer_utm)
           ID YEAR MONTH DAY HOUR MINUTE SECOND ALT Dim SAT1 SAT2 SAT3 SAT4
1 d16241y2011 2011     5   1    0      2     37 252   3    4   10   17   20
2 d16241y2011 2011     5   1    0     32     41 243   3    2    4   10   12
3 d16241y2011 2011     5   1    1      2     37 238   3    2    4    9   10
4 d16241y2011 2011     5   1    1     32     36 252   3    2    4    5    9
5 d16241y2011 2011     5   1    2      2     37 252   3    2    4    5    9
6 d16241y2011 2011     5   1    2     32     37 247   3    2    4    5    9
  SAT5 SAT6 SAT7 SAT8 SAT9 SAT10 SAT11 SAT12 PDOP HDOP  TEMP ACTIVITY TIMEON
1   28    0    0    0    0     0     0     0  3.8  2.8 25.75      473     37
2   17   28    0    0    0     0     0     0  2.2  1.2 27.69        0     41
3   12   17   27    0    0     0     0     0  2.6  1.1 25.19      631     37
4   10   12   17   27    0     0     0     0  2.4  1.1 25.31      485     36
5   10   12   17   25    0     0     0     0  1.7  0.9 25.44      127     37
6   10   12   17   25    0     0     0     0  1.6  1.0 25.31      215     37
              date               date1               POSIX        X       Y
1  5/1/2011 0:2:37 2011-05-01 00:02:37 2011-05-01 00:02:37 660574.7 3765194
2 5/1/2011 0:32:41 2011-05-01 00:32:41 2011-05-01 00:32:41 660571.5 3765193
3  5/1/2011 1:2:37 2011-05-01 01:02:37 2011-05-01 01:02:37 660549.3 3765170
4 5/1/2011 1:32:36 2011-05-01 01:32:36 2011-05-01 01:32:36 660533.8 3764965
5  5/1/2011 2:2:37 2011-05-01 02:02:37 2011-05-01 02:02:37 660548.6 3764950
6 5/1/2011 2:32:37 2011-05-01 02:32:37 2011-05-01 02:32:37 660562.0 3764956

Convert to ‘ltraj’ Trajectory

  • Spatial Coordinates
  • Date/Time
  • ID
  • “INFOLOCS” = other data
deer_utm$POSIX <- as.POSIXct(deer_utm$date1)
deer_ltraj <- as.ltraj(xy=deer_utm[,c('X','Y')], date = deer_utm$POSIX,
                       id = deer_utm$ID, infolocs=deer_utm[,c('PDOP','ACTIVITY')],
                       proj4string = CRS("+init=epsg:3158"))
deer_ltraj

*********** List of class ltraj ***********

Type of the traject: Type II (time recorded)
* Time zone unspecified: dates printed in user time zone *
Irregular traject. Variable time lag between two locs

Characteristics of the bursts:
           id       burst nb.reloc NAs          date.begin            date.end
1 d16241y2011 d16241y2011     1486   0 2011-05-01 00:02:37 2011-05-31 23:32:39
2 d16243y2011 d16243y2011     1480   0 2011-05-01 00:02:40 2011-05-31 23:32:37
3 d16244y2011 d16244y2011     1474   0 2011-05-01 00:02:36 2011-05-31 23:32:39
4 d16246y2011 d16246y2011     1481   0 2011-05-01 00:02:36 2011-05-31 23:32:40
5 d16247y2011 d16247y2011     1482   0 2011-05-01 00:02:37 2011-05-31 23:32:40
6 d16250y2011 d16250y2011     1474   0 2011-05-01 00:02:37 2011-05-31 23:32:37
7 d16252y2011 d16252y2011     1487   0 2011-05-01 00:02:40 2011-05-31 23:32:36
8 d16253y2011 d16253y2011     1473   0 2011-05-01 00:02:40 2011-05-31 23:32:36


 infolocs provided. The following variables are available:
[1] "PDOP"     "ACTIVITY"

Visualizing Wildlife Tracking Data

adehabitatLT package

  • default plots are IMO terrible
    • automatically plot all individuals in seperate tile
plot(deer_ltraj)

Maps in sf

  • Not bad, but could be better
plot(deersf_utm['ID'])

Mapview Package

  • Closest thing to interactive GIS window
library(mapview)
mapview(deersf_utm['ID'])

Quick Plotting Hack

  • Make lines from points to capture trajectory
deersf_utm_lines <- deersf_utm %>% 
  dplyr::group_by(ID) %>% 
  dplyr::summarise(do_union=FALSE) %>%
  st_cast("LINESTRING")
plot(deersf_utm_lines['ID'])

Combine Points and Lines in Mapview

  • suffers from visual overlap (spaghetti map)
mapview(deersf_utm_lines['ID']) + mapview(deersf_utm['ID'])

Combine Points and Lines in Mapview

deer46 <- subset(deersf_utm,ID=='d16246y2011')
deer46_lines <- subset(deersf_utm_lines,ID=='d16246y2011')

mapview(deer46_lines['ID']) + mapview(deer46['ID'])

Animating Tracking Data

  • Static maps are useful for papers and reports
  • Dynamic visualizations are more fun!
  • Animations are great in slides and presentations
  • Great for posting on the web/social media
  • Exploring patterns in your data

moveVis R Package

  • moveVis is built upon the move data objects
    • easy to convert ltraj to move object
  • requires additional downloads onto your laptop
library(moveVis)
library(move)

#Convert ltraj to move (focus on deer 46)
deer_move <- move(deer_ltraj[4])

MoveVis needs Lat/Long Coodinates?

x46 <- subset(x,ID=='d16246y2011')
deer_move <- move(x46$LONGITUDE,x46$LATITUDE,time=x46$POSIX,data=x46,proj=CRS("+init=epsg:4326"))

plot(deer_move)

Create Animation Frame-by-Frame

#need to regularize the track for animation - here we have ~30 minute data
m <- align_move(deer_move, res = 30, unit = "mins")
# create spatial frames with a OpenStreetMap map
frames <- frames_spatial(m, map_service = "osm", map_type = "topographic") %>% 
  add_northarrow() %>% 
  add_scalebar() %>% 
  add_timestamps(type = "label") %>% 
  add_progress()
Checking temporal alignment...
Processing movement data...
Approximated animation duration: ≈ 59.48s at 25 fps for 1487 frames
Retrieving and compositing basemap imagery...
Assigning raster maps to frames...
Creating frames...

Look at One Frame

frames[[100]] # preview one of the frames, e.g. the 100th frame
# animate frames takes 30 minutes for a 1 minute video (1487 frames)
#animate_frames(frames, out_file = "moveVis.gif")

Create moveVis GIF

# Recap 2: Maps and moveVis Animation

Maps in R using sf Hack

deersf_utm_lines <- deersf_utm %>% 
  dplyr::group_by(ID) %>% 
  dplyr::summarise(do_union=FALSE) %>%
  st_cast("LINESTRING")

plot(deersf_utm_lines['ID'])

Animations with moveVis

m <- align_move(deer_move, res = 30, unit = "mins")

frames <- frames_spatial(m, map_service = "osm", map_type = "topographic") %>% 
  add_northarrow() %>% 
  add_scalebar() %>% 
  add_timestamps(type = "label") %>% 
  add_progress()

animate_frames(frames, out_file = "moveVis.gif")

Analysis of Wildlife Tracking Data

Movement Data Properties

Key Measures from fixes: distance, bearing, turning angle, time interval, speed (distance/time)

Automatic in adehabitatLT

  • distance between fixes: dist
  • time between fixes: dt
  • bearing/direction: abs.angle
  • turning angle: rel.angle
         x       y                date          dx          dy       dist   dt
1 660574.7 3765194 2011-05-01 00:02:37  -3.1994740   -1.000569   3.352279 1804
2 660571.5 3765193 2011-05-01 00:32:41 -22.2005997  -23.099825  32.038547 1796
3 660549.3 3765170 2011-05-01 01:02:37 -15.4993129 -205.499354 206.083025 1799
4 660533.8 3764965 2011-05-01 01:32:36  14.7992122  -15.100248  21.143183 1801
5 660548.6 3764950 2011-05-01 02:02:37  13.4006177    6.499504  14.893627 1800
6 660562.0 3764956 2011-05-01 02:32:37   0.5001672   -2.200112   2.256249 1810
          R2n  abs.angle  rel.angle          id       burst PDOP ACTIVITY
1     0.00000 -2.8384991         NA d16241y2011 d16241y2011  3.8      473
2    11.23777 -2.3363468  0.5021522 d16241y2011 d16241y2011  2.2        0
3  1225.99270 -1.6460765  0.6902704 d16241y2011 d16241y2011  2.6      631
4 54388.80363 -0.7954661  0.8506104 d16241y2011 d16241y2011  2.4      485
5 60559.30681  0.4515881  1.2470542 d16241y2011 d16241y2011  1.7      127
6 56900.75264 -1.3472585 -1.7988466 d16241y2011 d16241y2011  1.6      215

Movement Metrics in adehabitatLT

  • step-characteristics associated with first fix (dist, dt, abs.angle)
    • NA values in last row (n fixes -> n-1 steps)
  • turning angle associated with middle of three fixes (rel.angle)
    • NA values in first and last row (n-1 steps -> n-2 turns)

Accessing Movement Metrics

  • Convert back to data.frame
library(ggplot2)
deerdf <- ld(deer_ltraj)
ggplot(deerdf, aes(x = dist, fill = id)) +                    
  geom_histogram(position="identity",alpha=0.2,bins=50) +
  scale_x_continuous(trans='log')

Movement Step Velocities

deerdf$vi <- deerdf$dist / deerdf$dt #step velocity in m/s
deer_ltraj <- dl(deerdf) #convert back to ltraj
ggplot(deerdf, aes(x=id, y = vi)) +                    
  geom_boxplot() +
  scale_y_continuous(trans='log')

Net-Displacement

  • Net (not cumulative) distance from origin point
    • often ‘First Fix’
  • Sometimes use \(\sqrt{nD}\) (squared-net displacement)
    • statistical properties
  • Maximum displacement (furthest point from origin)

Net Displacement

ggplot(deerdf, aes(x = date, y=R2n/1000, colour = id)) +                    
  geom_line()

First Passage Time

  • Similar conceptually to nD
    • Focuses on time
  • Time to reach a given radial distance
    • from origin fix
  • Often used to study dispersion

First Passage Time

  • FPT low = active movement
  • FPT high = stationary periods
  • This deer is relatively active

First Passage Time

  • Different individual, different pattern
  • What behaviour are we seeing here?
  • How might we think about ‘scale’?

Analysis Scale

  • The scale at which we analyze tracking data matters
    • space
    • time
  • Movement metrics and related analysis depend on scale of data and analysis

Space Use

Classifying Behaviour

Studying Interactions

Excercise 4: Calculating Home Ranges

Summary